package com.example.myapplication.slice;

import com.example.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class YesterdayMonitorDataSlice extends AbilitySlice {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_yesterday_monitor_data2);

        Button todayDataButton = findComponentById(ResourceTable.Id_today_data_button2);
        Button historyDataButton = findComponentById(ResourceTable.Id_history_data_button2);
        Button yesterdayBackIndexButton = findComponentById(ResourceTable.Id_yesterday_back_index_button2);
        Component.ClickedListener listener = new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if (component == todayDataButton) {
                    present(new TodayMonitorDataSlice(), new Intent());
                } else if (component == historyDataButton) {
                    present(new HistoryMonitorDataSlice(), new Intent());
                }else if (component == yesterdayBackIndexButton){

                }
            }
        };
        todayDataButton.setClickedListener(listener);
        historyDataButton.setClickedListener(listener);
        yesterdayBackIndexButton.setClickedListener(listener);

    }
}
